package com.mfanw.springmvc.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mfanw.springmvc.dao.UserMapper;
import com.mfanw.springmvc.model.User;
import com.mfanw.springmvc.service.UserServiceI;

@Service("userService")
public class UserServiceImpl implements UserServiceI {

	private UserMapper userMapper;

	public User getUser(String id) {
		return userMapper.getUserByPrimaryKey(id);
	}

	public UserMapper getUserMapper() {
		return userMapper;
	}

	@Autowired
	public void setUserMapper(UserMapper userMapper) {
		this.userMapper = userMapper;
	}

	public void insertUser(User user) {
		userMapper.insert(user);
	}

	public void insertUserSelective(User user) {
		userMapper.insertSelective(user);
	}

	public void deleteUser(String id) {
		userMapper.deleteByPrimaryKey(id);
	}

	public void deleteUser(User user) {
		userMapper.deleteByPrimaryKey(user.getId());
	}

	public int updateUser(User user) {
		return userMapper.updateByPrimaryKey(user);
	}

	public int updateUserSelective(User user) {
		return userMapper.updateByPrimaryKeySelective(user);
	}

	public List<User> getUserAll() {
		return userMapper.getUserAll();
	}

}
